<?php

namespace app\controller\api\sdk;

use app\caches\AdPlanCache;
use app\services\ad\monitor\MonitorBase;
use support\Request;

class AdMonitorController
{
    public function mediaMonitor(Request $request)
    {
        $plan_id = $request->input('plan_id') ?? 0;
        $plan = AdPlanCache::getInstance()->remember($plan_id);
        if (empty($plan)) {
            return yqerr(6003);
        }

        $monitor = MonitorBase::getClass($plan['media_docking_id']);
        if (!$monitor) {
            return yqerr(6004);
        }

        return $monitor->handleMonitorInfo($request);
    }
}
